//
//  UINavigationController+pushJump.m
//  iOS_beboy
//
//  Created by wen on 2017/10/23.
//  Copyright © 2017年 com.8xiong. All rights reserved.
//

#import "UINavigationController+pushJump.h"
#import <objc/runtime.h>

@implementation UINavigationController (pushJump)

+ (void)load{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Method method1 = class_getInstanceMethod(self, @selector(pushViewController:animated:));
        Method method2 = class_getInstanceMethod(self, @selector(new_pushViewController:animated:));
        method_exchangeImplementations(method1, method2);
    });
}

- (void)new_pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [self new_pushViewController:viewController animated:animated];
    // 修改tabBra的frame
    CGRect frame = self.tabBarController.tabBar.frame;
    frame.origin.y = [UIScreen mainScreen].bounds.size.height - frame.size.height;
    self.tabBarController.tabBar.frame = frame;
}

@end
